<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var arr1 = [1, 2, 3, 4]
        var arr2 = [1, 2, 3, 4, 5, 6, 7, 8]
        function getArrDifference(arr1, arr2) {
            return arr1.concat(arr2).filter(function (v, i, arr) {
                return arr.indexOf(v) === arr.lastIndexOf(v);
            });
        }


        var arr3 = [{ id: 1, name: 11 }, { id: 2, name: 22 },
        { id: 3, name: 33 }, { id: 4, name: 4 }, { id: 5, name: 55 }]
        var arr4 = [{ id: 1, name: 11 }, { id: 3, name: 33 }]
        function arraySet(array1, array2) {
            var result = [];
            for (var i = 0; i < array2.length; i++) {
                var obj = array2[i];
                var num = obj.id;
                var isExist = false;
                for (var j = 0; j < array1.length; j++) {
                    var aj = array1[j];
                    var n = aj.id;
                    if (n == num) {
                        isExist = true;
                        break;
                    }
                }
                if (!isExist) {
                    result.push(obj);
                }
            }
            return result
        }
        var res = arraySet(arr4, arr3)
        console.log(res, 6666);




    </script>
</body>

</html>